const { DataTypes, Model } = require('sequelize')

const { datasource } = require('../index.cjs')

class Task extends Model {
}

/**
 * @type {Record<any, import('sequelize').DataType | import('sequelize').ModelAttributeColumnOptions<Task>>}
 */
const attrs = {
	id: {
		type: DataTypes.INTEGER,
		autoIncrement: true,
		primaryKey: true
	},
	name: {
		type: DataTypes.STRING,
		comment: '任务名称'
	},
	remark: {
		type: DataTypes.STRING,
		comment: '任务详情'
	},
	createTime: {
		type: DataTypes.DATE,
		comment: '创建时间',
		defaultValue: () => new Date()
	},
	completeTime: {
		type: DataTypes.DATE,
		comment: '完成时间',
		defaultValue: () => null
	}
}

Task.init(attrs, { sequelize: datasource, modelName: 'Task' })

module.exports = { Task }
